 <style type="text/css">
    .monthlyCost
	{
    color: #FF0000;
    font-weight: bold; 
	}
</style>
<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); 
/**
*
* @version $Id: ro_basket_b2b.html.php 1377 2008-04-19 17:54:45Z gregdev $
* @package VirtueMart
* @subpackage templates
* @copyright Copyright (C) 2004-2005 Soeren Eberhardt. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
	function getSelectedMonthlyPayment($pclass_id)
	{
		if(!isset($pclass_id))
			return 0;
		
		if($_COOKIE['monthlyPaymentSelected'] == 0)
		{
			return 0;
		}
		
		
		
		define('ABSLPATH1', dirname(__FILE__).'/');
		
		$shorten_path1 = substr(ABSLPATH1, 0, -8);
		$shorten_path1 .= "payment/ps_kreditor_del.php";
		
		if(file_exists($shorten_path1))
			include_once($shorten_path1);
		else
		{
			define('ABSLPATH2', dirname(__FILE__).'/');
			$shorten_path2 = substr(ABSLPATH2, 0, -58-$themelength);
			$shorten_path2 .= "administrator/components/com_virtuemart/classes/payment/ps_kreditor_del.php";	
			
			if(file_exists($shorten_path2))
				include_once($shorten_path2);
			else
			{
				echo "REPORT THESE lines to Kreditor/Klarna technical support!<br />";
				echo "These include error where tried for ps_kreditor_del<br />";
				echo $shorten_path1 . "<br />" . $shorten_path2 . "<br />";
			}
		}
		
		define('ABSLPATH3', dirname(__FILE__).'/');
		$shorten_path3 = substr(ABSLPATH3, 0, -8);
		$shorten_path3 .= "payment/ps_kreditor.cfg.php";
		
		if(file_exists($shorten_path3))
			include_once($shorten_path3);
		else
		{
			define('ABSLPATH4', dirname(__FILE__).'/');
			$shorten_path4 = substr(ABSLPATH4, 0, -56-$themelength);
			$shorten_path4 .= "administrator/components/com_virtuemart/classes/payment/ps_kreditor.cfg.php";	
			
			if(file_exists($shorten_path4))
				include_once($shorten_path4);
			else
			{
				define('ABSLPATH5', dirname(__FILE__).'/');
				$shorten_path5 = substr(ABSLPATH5, 0, -56-$themelength);
				$shorten_path5 .= "administrator/components/com_virtuemart/classes/payment/ps_kreditor.cfg.php";
				
				if(file_exists($shorten_path5))
					include_once($shorten_path5);
				else
				{
					echo "REPORT THESE lines to Kreditor/Klarna technical support!<br />";
					echo "These include error where tried for ps_kreditor.cfg.php<br />";
					echo $shorten_path3 . "<br />" . $shorten_path4 . "<br />" . $shorten_path5 . "<br />";
				}
			}
		}
	
		$db = new ps_DB;
		//mysql_query("SET NAMES 'utf8'");
		
		$q = "SELECT * from #__{vm}_kreditor_pclass WHERE pclass_id='$pclass_id'";
		$db->query($q);
		
		$currency = $db->f("currency");
		
		if($_SESSION['order_total_cost'] <= 0)
			$usedSum = $_COOKIE['monthlyCostTotal'];
		else
			$usedSum = $_SESSION['order_total_cost'];

		getMontlyCost($usedSum*100, $db->f("pclass_id"), 1, $result);
		//$monthly_payment = calcMonthlyCost($usedSum, $db->f("pclass_id"), $db->f("interest"), $db->f("months"), $db->f("handlingfee"), $currency, 0);
		
		return $result;
	}
?>
<table width="100%" cellspacing="2" cellpadding="4" border="0">
  <tr align="left" class="sectiontableheader">
        <th><?php echo $VM_LANG->_('PHPSHOP_CART_NAME') ?></th>
        <th><?php echo $VM_LANG->_('PHPSHOP_CART_SKU') ?></th>
	<th><?php echo $VM_LANG->_('PHPSHOP_CART_PRICE') ?></th>
	<th><?php echo $VM_LANG->_('PHPSHOP_CART_QUANTITY') ?></th>
	<th><?php echo $VM_LANG->_('PHPSHOP_CART_SUBTOTAL') ?></th>
  </tr>
<?php foreach( $product_rows as $product ) { ?>
  <tr valign="top" class="<?php echo $product['row_color'] ?>">
	<td><?php echo $product['product_name'] . $product['product_attributes'] ?></td>
    <td><?php echo $product['product_sku'] ?></td>
    <td align="right"><?php echo $product['product_price'] ?></td>
    <td><?php echo $product['quantity'] ?></td>
    <td align="right"><?php echo $product['subtotal'] ?></td>
  </tr>
<?php } ?>
<!--Begin of SubTotal, Tax, Shipping, Coupon Discount and Total listing -->
  <tr class="sectiontableentry1">
    <td colspan="4" align="right"><?php echo $VM_LANG->_('PHPSHOP_CART_SUBTOTAL') ?>:</td> 
    <td align="right"><?php echo $subtotal_display ?></td>
  </tr>
<?php if( $payment_discount_before ) { ?>
  <tr class="sectiontableentry1">
    <td colspan="4" align="right"><?php echo $discount_word ?>:
    </td> 
    <td align="right"><?php echo $payment_discount_display ?></td>
  </tr>
<?php } 
if( $coupon_discount_before ) { ?>
  <tr class="sectiontableentry1">
    <td colspan="4" align="right"><?php echo $VM_LANG->_('PHPSHOP_COUPON_DISCOUNT') ?>:
    </td> 
    <td align="right"><?php echo $coupon_display ?></td>
  </tr>
<?php 
}
if( $shipping ) { ?>
  <tr class="sectiontableentry1">
	<td colspan="4" align="right"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_SHIPPING') ?>: </td> 
	<td align="right"><?php echo $shipping_display ?></td>
  </tr>
<?php }
$langInfo = new Singleton("language");
if($_COOKIE["monthlyPaymentSelected"] == 3)
{
	require_once(CLASSPATH . 'klarna_util.php');
 ?>
<tr class="sectiontableentry1">
			<td colspan="4" align="right" valign="top"><?php echo $langInfo->TEXT_INVOICE_COST ?>: </td> 
			<?php
			$finalStatement = (getKlarnaInvoiceCost() / ((getKlarnaInvoiceTax() / 100) + 1));
			$finalStatement = $GLOBALS['CURRENCY_DISPLAY']->getFullValue($finalStatement); ?>
			<td colspan="3" align="right"><?php echo $finalStatement ?></td>
	  </tr>
<?php
// xxx Calculate the total tax including the invoice fee
// xxx Remove all characters in front of the sum
$tax_display = preg_replace('/(&.*;)/i', '', $tax_display);
$tax_display = preg_replace('/([^0-9\.,]*)/i', '', $tax_display);
$tax_display = str_replace(',','.',$tax_display);
$tax_display += getKlarnaInvoiceCost() - (getKlarnaInvoiceCost() / ((getKlarnaInvoiceTax() / 100) + 1));
$tax_display = $GLOBALS['CURRENCY_DISPLAY']->getFullValue($tax_display);
}	  
	elseif($_COOKIE['monthlyPaymentSelected'] == 1 || $_COOKIE['monthlyPaymentSelected'] == 2) { // This is only shown in the "The Complete Order", Monthly Cost! ?>
	  <tr class="sectiontableentry1">
			<td colspan="4" align="right" valign="top"><?php echo $langInfo->TEXT_MONTHLY_COST ?>: </td> 
			<?php
			
			
			$finalStatement = getSelectedMonthlyPayment($_COOKIE['pclass']);
			
			if($finalStatement == 0)
			{
				$finalStatement = "No monthly payment selected, try again!";
				?><script type="text/javascript">alert("Please go back and try again!");</script><?php
			}
			else
			{
				$finalStatement = Round($finalStatement / 100, 0);
				$currency_display = ps_vendor::get_currency_display_style( $vendor_currency_display_style );
				if( $GLOBALS['product_currency'] != $vendor_currency ) {
					$currency_display["symbol"] = $GLOBALS['product_currency'];
				}
				$GLOBALS['CURRENCY_DISPLAY3'] = new CurrencyDisplay($currency_display["id"], $currency_display["symbol"], 0, $currency_display["sdecimal"], $currency_display["thousands"], $currency_display["positive"], $currency_display["negative"]);
				$finalStatement = $GLOBALS['CURRENCY_DISPLAY3']->getFullValue($finalStatement); 
			}
			?>
			<td colspan="3" align="right"><span class="monthlyCost"><?php echo $finalStatement ?></span></td>
	  </tr>
	<?php }

if ( $tax ) { ?>
  <tr class="sectiontableentry1">
        <td colspan="4" align="right" valign="top"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_TOTAL_TAX') ?>: </td> 
        <td align="right"><?php echo $tax_display; ?></td>
  </tr>
<?php }
if( $payment_discount_after ) { ?>
  <tr class="sectiontableentry1">
    <td colspan="4" align="right"><?php echo $discount_word ?>:
    </td> 
    <td align="right"><?php echo $payment_discount_display ?></td>
  </tr>
<?php } 
if( $coupon_discount_after ) { ?>
  <tr class="sectiontableentry1">
    <td colspan="4" align="right"><?php echo $VM_LANG->_('PHPSHOP_COUPON_DISCOUNT') ?>:
    </td> 
    <td align="right"><?php echo $coupon_display ?></td>
  </tr>
<?php 
}
?>
  <tr>
    <td colspan="3">&nbsp;</td>
    <td colspan="2"><hr /></td>
  </tr>
  <tr class="sectiontableentry1">
    <td colspan="4" align="right"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_TOTAL') ?>: </td>
    <td align="right"><strong><?php echo $order_total_display ?></strong>
    </td>
  </tr>
  <tr>
    <td colspan="5"><hr /></td>
  </tr>
</table>
